{ open Parser }

rule token = parse
  [' ' '\t' '\r' '\n'] { token lexbuf }
| '(' {LPAREN}        | ')' {RPAREN}
| '{' {LBRACE}        | '}' {RBRACE}
| '[' {LSQUA}         | ']' {RSQUA}
| '"' {DQUOTATION}    | '\''{SQUOTATION}
| ',' {COMMA}
| '.' {PERIOD}
| ';' {SEMI}
| '+' { PLUS }        | "+."{FPLUS}
| '-' { MINUS }       | "-."{FMINUS}
| '*' { TIMES }       | "*."{FTIMES}
| '/' { DIVIDE }      | "/."{FDIVIDE}
| '=' {ASSIGN}        
| "=="{EQ}            | "!="{NEQ}
| '>' {GT}            | '<' {LT}
| ">="{GEQ}           | "<="{LEQ}
| "&&"{AND}           | "||"{OR}
| '!' {NOT}
| "int" {INT}
| "float" {FLO}
| "string" {STRINGV}
| "StringList" {SLIST}
| "return" {RETURN}
| "while"  {WHILE}
| "if"     {IF}       |"else"  {ELSE}
| "StringHash"  {SHASH}
| "SlistHash"   {SLHASH}
| "add"         {ADD}      |"create"    {CREATE}
| "mem"         {MEM}      |"find"      {FIND}
| "print"       {PRINT} 
| "intersect"   {INTERSECT}
| ['0'-'9']+ as lxm { LITERAL(int_of_string lxm) }
| ['0'-'9']+ '.' ['0'-'9']+ as lxm {FLOAT(float_of_string lxm)}
| ['a'-'z' 'A'-'Z']['a'-'z' 'A'-'Z' '0'-'9' '_']* as lxm {ID(lxm)}
| '\'' ['a'-'z' 'A'-'Z' '0'-'9' '_'] '\'' as lxm {CHAR(lxm.[1])}
|'"' ['a'-'z' 'A'-'Z' '0'-'9' ' ' '_']* '"' as lxm {STR(lxm)}
| _ as char {raise (Failure("illegal character" ^ Char.escaped char))}
| eof { EOF }
